package com.nytd.demo.controller;

import com.nytd.demo.pojo.request.UserLoginRequest;
import com.nytd.demo.pojo.response.UserInfoResponse;
import com.nytd.demo.pojo.response.UserLoginResponse;
import com.nytd.demo.service.UserInfoService;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserInfoController {
    @Resource(name = "userInfoService")
    private UserInfoService userInfoService;

    @PostMapping("/login")
    public UserLoginResponse login(@RequestBody @Validated UserLoginRequest request) {
        log.info("用户登录，userName : {}", request.getUserName());
        return userInfoService.check(request);
    }
    @GetMapping("/getUserInfo")
    public UserInfoResponse getUserInfo(@NotNull Integer userId) {
        return userInfoService.getUserInfo(userId);
    }
    @GetMapping("/getAuthorInfo")
    public UserInfoResponse getAuthorInfo(@NotNull Integer blogId) {
        return userInfoService.getAuthorInfo(blogId);
    }

}
